package com.link2room.soundwave.service.impl;

import com.link2room.common.constant.DefaultValue;
import com.link2room.common.jpa.result.QueryResult;
import com.link2room.common.util.*;
import com.link2room.enums.exception.SoundwaveSysExceptionEnum;
import com.link2room.soundwave.exception.SoundwaveException;
import com.link2room.soundwave.constant.YhPmsConstant;
import com.link2room.soundwave.service.IYhPmsMemberService;
import com.link2room.soundwave.util.YhPmsUtil;
import org.apache.http.Header;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import yuheng.pms.param.YhMemberInfoRequestParamDto;
import yuheng.pms.result.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

/**
 * Created by sss on 2017/6/7.
 */
@Service("yhPmsMemberService")
public class YhPmsMemberServiceImpl implements IYhPmsMemberService {

	private static final Logger logger = LoggerFactory.getLogger(YhPmsMemberServiceImpl.class);
	
    @Override
    public YhMemberInfoDto getYhPmsMemberInfo(String lhotelGroupCode, String pmsHotelGroupCode, String mobile) throws Exception {
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        String uri=clientIp+"/"+"api/Card/GetCardInfoByCondition";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setPhone(mobile);
        //yhMemberInfoRequestParamDto.setName(memberName);
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody=HttpUtil.httpPost(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Map data=(Map) map.get("Data");
        YhMemberInfoDto yhMemberInfoDto=null;
        if(true==(boolean)map.get("Success")){
            yhMemberInfoDto=new YhMemberInfoDto();
            yhMemberInfoDto.setHotelCode((String) data.get("HotelCode"));
            yhMemberInfoDto.setGroupCode((String) data.get("GroupCode"));
            yhMemberInfoDto.setBalance((String) data.get("Balance"));
            yhMemberInfoDto.setCardNo((String) data.get("CardNo"));
            yhMemberInfoDto.setCardType("SSAW");
            yhMemberInfoDto.setName((String) data.get("Name"));
            yhMemberInfoDto.setCardLevel((String) data.get("CardType"));
            yhMemberInfoDto.setCustomerId((String) data.get("CustomerId"));
            yhMemberInfoDto.setExpireDate(DateUtil.parseDateStandardFormat((String) data.get("ExpireDate")));
            Double freezePoints=(Double) data.get("FreezePoints");
            if(freezePoints!=null){
                yhMemberInfoDto.setFreezePoints(new BigDecimal(freezePoints));
            }
            Double points=(Double) data.get("Points");
            if(points!=null){
                yhMemberInfoDto.setPoints(new BigDecimal(points));
            }
            yhMemberInfoDto.setBalance((String) data.get("Balance"));
            yhMemberInfoDto.setOpenId((String) data.get("OpenId"));
            yhMemberInfoDto.setTotalTimes((String) data.get("TotalTimes"));
            yhMemberInfoDto.setStatus((String) data.get("Status"));
            yhMemberInfoDto.setSerialNo((String) data.get("SerialNo"));
            yhMemberInfoDto.setRecName((String) data.get("RecName"));
            yhMemberInfoDto.setRecCardNo((String) data.get("RecCardNo"));
        }
        return yhMemberInfoDto;
    }

    @Override
    public void bindYhPmsMemberInfo(String lhotelGroupCode,
                                    String pmsHotelGroupCode,
                                    String serialNo,
                                    String cardNo,
                                    String openId)throws Exception{
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        String uri=clientIp+"/"+"api/Card/UpdateCardOpenId";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setSerialNo(serialNo);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setOpenId(openId);
        yhMemberInfoRequestParamDto.setOptUserName(DefaultValue.LINK2ROOM);
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody=HttpUtil.httpPut(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        if(false==(boolean)map.get("Success")){
            throw new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_BINDMEMBER_ERROR);
        }
    }

    @Override
    public List<YhCardNoDto> getCardsNoList(String lhotelGroupCode,
                                            String pmsHotelGroupCode)throws Exception{
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel,"默认会员等级不存在");
        String uri=clientIp+"/"+"api/Card/GetCardsNoList";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setCardType(cardLevel);
        yhMemberInfoRequestParamDto.setStatus("A");
        yhMemberInfoRequestParamDto.setPageIndex(0);
        yhMemberInfoRequestParamDto.setPageSize(20);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode, YhPmsConstant.MEMBER_REQ);
        String responseBody=HttpUtil.httpPost(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
       /* String dataJson=JacksonUtil.beanToJson(map.get("Data"));
        ArrayList<YhCardNoDto> yhCardNoDtos= JacksonUtil.jsonToBeanByJavaType(dataJson,ArrayList.class,YhCardNoDto.class);
*/
        List<YhCardNoDto> yhCardNoDtos=new ArrayList<>();
        List<Map<String,Object>> dataMapList=(List<Map<String,Object>>)map.get("Data");
        YhCardNoDto yhCardNoDto=null;
        for(Map<String,Object> dataMap:dataMapList){
            yhCardNoDto=new YhCardNoDto();
            yhCardNoDto.setCardNo((String) dataMap.get("CardNo"));
            yhCardNoDto.setId((Integer) dataMap.get("Id"));
            yhCardNoDto.setCardType((String) dataMap.get("CardType"));
            yhCardNoDto.setStatus((String) dataMap.get("Status"));
            yhCardNoDto.setCreatetime(DateUtil.parseDateStandardFormat((String)dataMap.get("Createtime")));
            yhCardNoDto.setCreateuser((String) dataMap.get("Createuser"));
            yhCardNoDto.setIntervalId((Integer) dataMap.get("IntervalId"));
            yhCardNoDto.setModifytime(DateUtil.parseDateStandardFormat((String)dataMap.get("Modifytime")));
            yhCardNoDto.setGroupCode((String) dataMap.get("GroupCode"));
            yhCardNoDto.setHotelCode((String) dataMap.get("HotelCode"));
            yhCardNoDtos.add(yhCardNoDto);
        }
        return yhCardNoDtos;
    }

    @Override
    public YhCardNoDto getCardNo(String lhotelGroupCode,
                                 String pmsHotelGroupCode)throws Exception{
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel,"默认会员等级不存在");
        String uri=clientIp+"/"+"api/Card/GetLockCardNo";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode("0000000");
        yhMemberInfoRequestParamDto.setCardType(cardLevel);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode, YhPmsConstant.MEMBER_REQ);
        String responseBody=HttpUtil.httpPost(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
       /* String dataJson=JacksonUtil.beanToJson(map.get("Data"));
        ArrayList<YhCardNoDto> yhCardNoDtos= JacksonUtil.jsonToBeanByJavaType(dataJson,ArrayList.class,YhCardNoDto.class);
*/
        Map<String,Object> dataMap=(Map<String,Object>)map.get("Data");
        YhCardNoDto yhCardNoDto=new YhCardNoDto();
        yhCardNoDto.setCardNo((String) dataMap.get("CardNo"));
        yhCardNoDto.setId((Integer) dataMap.get("Id"));
        yhCardNoDto.setCardType((String) dataMap.get("CardType"));
        yhCardNoDto.setStatus((String) dataMap.get("Status"));
        yhCardNoDto.setCreatetime(DateUtil.parseDateStandardFormat((String)dataMap.get("Createtime")));
        yhCardNoDto.setCreateuser((String) dataMap.get("Createuser"));
        yhCardNoDto.setIntervalId((Integer) dataMap.get("IntervalId"));
        yhCardNoDto.setModifytime(DateUtil.parseDateStandardFormat((String)dataMap.get("Modifytime")));
        yhCardNoDto.setGroupCode((String) dataMap.get("GroupCode"));
        yhCardNoDto.setHotelCode((String) dataMap.get("HotelCode"));
        return yhCardNoDto;
    }

    @Override
    public List<YhCardTypeRuleDto> getCardTypeRule(String lhotelGroupCode,
                                                   String pmsHotelGroupCode,
                                                   String pmsHotelCode,
                                                   String cardType)throws Exception{
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        if(StringUtil.isNotBlank(pmsHotelCode)){
            hotelCode=pmsHotelCode;
        }
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel,"默认会员等级不存在");
        String uri=clientIp+"/"+"api/CardType/GetCardGradeRuleList";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setCardType(cardLevel);
        yhMemberInfoRequestParamDto.setFromCardType(cardType);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode, YhPmsConstant.MEMBER_REQ);
        String responseBody=HttpUtil.httpPost(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Optional<Map> mapOptional=Optional.ofNullable(map);
        mapOptional.filter(map1 ->true==(boolean)map.get("Success")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_GET_CARDTYPE_RULE_ERROR));
        List<Map<String,Object>> dataMapList=mapOptional.map(map1 ->(List<Map<String,Object>>) map1.get("Data")).orElse(Collections.emptyList());
        return dataMapList.stream().map(dataMap->{
            YhCardTypeRuleDto yhCardTypeRuleDto=new YhCardTypeRuleDto();
            yhCardTypeRuleDto.setGroupCode((String) dataMap.get("GroupCode"));
            yhCardTypeRuleDto.setHotelCode((String) dataMap.get("HotelCode"));
            yhCardTypeRuleDto.setAmount(new BigDecimal((Double)dataMap.get("Amount")));
            yhCardTypeRuleDto.setPoints(new BigDecimal((Double) dataMap.get("Points")));
            yhCardTypeRuleDto.setRelation((String) dataMap.get("Relation"));
            yhCardTypeRuleDto.setFromCardType((String) dataMap.get("FromCardType"));
            yhCardTypeRuleDto.setToCardType((String) dataMap.get("ToCardType"));
            yhCardTypeRuleDto.setStatus((String) dataMap.get("Status"));
            return yhCardTypeRuleDto;
        }).collect(Collectors.toList());
    }

    @Override
    public void upgradeCard(String lhotelGroupCode,
                            String pmsHotelGroupCode,
                            String pmsHotelCode,
                            String cardNo,
                            String serialNo,
                            String fromCardType,
                            String toCardType,
                            Double amount,
                            Integer point,
                            String pmsSalesmanNo)throws Exception{
        String clientIp= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY,YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel= SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY,YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode,"默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel,"默认会员等级不存在");
        String uri=clientIp+"/"+"api/Card/UpgradeCard";
        if(StringUtil.isNotBlank(pmsHotelCode)){
            hotelCode=pmsHotelCode;
        }
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto=new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setFromCardType(fromCardType);
        yhMemberInfoRequestParamDto.setToCardType(toCardType);
        yhMemberInfoRequestParamDto.setPoints(point);
        yhMemberInfoRequestParamDto.setAmount(amount);
        yhMemberInfoRequestParamDto.setModifyUser("lfwx");
        yhMemberInfoRequestParamDto.setRemarks("lfwx");
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setSerialNo(serialNo);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setSalesId(pmsSalesmanNo);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode, YhPmsConstant.MEMBER_REQ);
        String responseBody=HttpUtil.httpPut(uri,yhMemberInfoRequestParamDto,headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Optional<Map> mapOptional=Optional.ofNullable(map);
        mapOptional.filter(map1 ->true==(boolean)map.get("Success")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_CARD_UPGRADE_ERROR));
    }

    @Override
    public YhMemberInfoDto newYuHengPmsMember(String lhotelGroupCode,
                                              String pmsHotelGroupCode,
                                              String memberName,
                                              String mobile,
                                              String cardNo,
                                              String openId,
                                              String pmsSalesmanNo,
                                              String l2rMemberNo) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/Card/OpenCard";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setName(memberName);
        yhMemberInfoRequestParamDto.setSex(0);
        yhMemberInfoRequestParamDto.setPhone(mobile);
        yhMemberInfoRequestParamDto.setIdentityType(0);
        yhMemberInfoRequestParamDto.setIdentityNo(mobile);
        yhMemberInfoRequestParamDto.setCardType(cardLevel);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setIsSell(false);
        yhMemberInfoRequestParamDto.setPrice(0);
        yhMemberInfoRequestParamDto.setOpenId(openId);
        yhMemberInfoRequestParamDto.setCreateUser(DefaultValue.LINK2ROOM);
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode("0000000");
        yhMemberInfoRequestParamDto.setSalesId(pmsSalesmanNo);
        yhMemberInfoRequestParamDto.setAppId("lfwx");
        yhMemberInfoRequestParamDto.setBusinessSerialNo(l2rMemberNo);
        yhMemberInfoRequestParamDto.setPrice(0);
        yhMemberInfoRequestParamDto.setPoints(0);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        YhMemberInfoDto yhMemberInfoDto=new YhMemberInfoDto();
        if((boolean)map.get("Success")){
            yhMemberInfoDto.setSuccess(true);
        }else {
            yhMemberInfoDto.setSuccess(false);
            LogUtil.logger.error("newYuHengPmsMember:"+yhMemberInfoRequestParamDto.toString());
        }
        yhMemberInfoDto.setCode((Integer)map.get("Code"));
        yhMemberInfoDto.setMessage((String)map.get("Message"));
        return yhMemberInfoDto;
    }

    @Override
    public List<YhCardPointDto> getYhPmsMemberPointsDetail(String lhotelGroupCode, String pmsHotelGroupCode, String serialNo, String cardNo) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/UserPoints/GetUserPointsDetail";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setSerialNo(serialNo);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        List<YhCardPointDto> yhCardPointDtos=new ArrayList<>();
        List<Map<String,Object>> dataMapList=(List<Map<String,Object>>)map.get("Data");
        YhCardPointDto yhCardPointDto=null;
        for(Map<String,Object> dataMap:dataMapList){
            yhCardPointDto=new YhCardPointDto();
            yhCardPointDto.setCardNo((String) dataMap.get("CardNo"));
            yhCardPointDto.setId((Integer) dataMap.get("Id"));
            yhCardPointDto.setSerialNo((String) dataMap.get("SerialNo"));
            yhCardPointDto.setStatus((String) dataMap.get("Status"));
            yhCardPointDto.setRemark((String) dataMap.get("Remark"));
            yhCardPointDto.setCreateUser((String) dataMap.get("CreateUser"));
            yhCardPointDto.setGroupCode((String) dataMap.get("GroupCode"));
            yhCardPointDto.setHotelCode((String) dataMap.get("HotelCode"));
            yhCardPointDto.setAccountno((String) dataMap.get("Accountno"));
            yhCardPointDto.setAddpointsUser((String) dataMap.get("AddpointsUser"));
            yhCardPointDto.setCancelRemark((String) dataMap.get("CancelRemark"));
            yhCardPointDto.setCancelUser((String) dataMap.get("CancelUser"));
            yhCardPointDto.setFeeCode((String) dataMap.get("FeeCode"));
            yhCardPointDto.setPointName((String) dataMap.get("PointName"));
            yhCardPointDto.setPointRule((String) dataMap.get("PointRule"));
            yhCardPointDto.setCreateTime(DateUtil.parseDateStandardFormat((String)dataMap.get("CreateTime")));
            yhCardPointDto.setPointsInValidDate(DateUtil.parseDateStandardFormat((String)dataMap.get("PointsInValidDate")));
            yhCardPointDto.setBusinessDate(DateUtil.parseDateStandardFormat((String)dataMap.get("BusinessDate")));
            yhCardPointDto.setPointsDate(DateUtil.parseDateStandardFormat((String)dataMap.get("PointsDate")));
            yhCardPointDto.setCancelDate(DateUtil.parseDateStandardFormat((String)dataMap.get("CancelDate")));
            yhCardPointDto.setPoints((Double) dataMap.get("Points"));
            yhCardPointDto.setDebitsAmount((Double) dataMap.get("DebitsAmount"));
            yhCardPointDtos.add(yhCardPointDto);
        }
        return yhCardPointDtos;
    }

    @Override
    public void addYhPmsMemberPoints(String lhotelGroupCode, String pmsHotelGroupCode, String cardNo,Integer points,String remark) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/UserPoints/AddUserPointDetail";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setPoints(points);
        yhMemberInfoRequestParamDto.setCreateUser(DefaultValue.LINK2ROOM);
        if(StringUtil.isNotBlank(remark)){
            yhMemberInfoRequestParamDto.setRemark(remark);
        }else {
            yhMemberInfoRequestParamDto.setRemark("联房增加积分");
        }
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        if(false==(boolean)map.get("Success")){
            throw new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_ADDPOINT_ERROR);
        }
    }

    @Override
    public void useYhPmsMemberPoints(String lhotelGroupCode, String pmsHotelGroupCode, String cardNo, Integer points, String remark) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/UserPoints/ReduceUserPointDetail";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setPoints(points);
        yhMemberInfoRequestParamDto.setCreateUser(DefaultValue.LINK2ROOM);
        if(StringUtil.isNotBlank(remark)){
            yhMemberInfoRequestParamDto.setRemark(remark);
        }else {
            yhMemberInfoRequestParamDto.setRemark("联房消费积分");
        }
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        if(false==(boolean)map.get("Success")){
            throw new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_USEPOINT_ERROR);
        }
    }

    @Override
    public QueryResult<YhCouponDto> getYhPmsMemberCoupons(String lhotelGroupCode, String pmsHotelGroupCode, String cardNo,
                                                      String pmsHotelCode,String pmsRmtype,Date arr,Date dep,BigDecimal minConsumeAmount,
                                                      Integer pageIndex,
                                                      Integer pageSize) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/SvcCard/Coupon/GetCoupon";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setStatus("A");
        yhMemberInfoRequestParamDto.setCancelHotelCode(pmsHotelCode);
        yhMemberInfoRequestParamDto.setCancelHotelTime(Optional.ofNullable(arr).map(time->DateUtil.getStandarDateString(time)).orElse(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)));
        yhMemberInfoRequestParamDto.setMinConsumeAmount(Optional.ofNullable(minConsumeAmount).map(value->value.doubleValue()).orElse(null));
        yhMemberInfoRequestParamDto.setPageIndex(pageIndex);
        yhMemberInfoRequestParamDto.setPageSize(pageSize);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Optional<Map> mapOptional=Optional.ofNullable(map);
        mapOptional.filter(map1 ->true==(boolean)map.get("Success")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_GET_COUPON_ERROR));
        List<Map<String,Object>> dataMapList=mapOptional.map(map1 ->(List<Map<String,Object>>) map1.get("Data")).orElse(Collections.emptyList());
        List<YhCouponDto> yhCouponDtoList =dataMapList.stream().map(dataMap->{
            YhCouponDto yhCouponDto=new YhCouponDto();
            yhCouponDto.setCardNo((String) dataMap.get("CardNo"));
            yhCouponDto.setId((Integer) dataMap.get("Id"));
            yhCouponDto.setSerialNo((String) dataMap.get("SerialNo"));
            yhCouponDto.setStatus((String) dataMap.get("Status"));
            yhCouponDto.setRemark((String) dataMap.get("Remark"));
            yhCouponDto.setCreateUser((String) dataMap.get("CreateUser"));
            yhCouponDto.setCreateDate(DateUtil.parseDateStandardFormat((String)dataMap.get("CreateDate")));
            yhCouponDto.setModifyUser((String) dataMap.get("ModifyUser"));
            yhCouponDto.setModifyDate(DateUtil.parseDateStandardFormat((String)dataMap.get("ModifyDate")));
            yhCouponDto.setGroupCode((String) dataMap.get("GroupCode"));
            yhCouponDto.setHotelCode((String) dataMap.get("HotelCode"));
            yhCouponDto.setActivityType((String) dataMap.get("ActivityType"));
            yhCouponDto.setCancelDate(DateUtil.parseDateStandardFormat((String)dataMap.get("CancelDate")));
            yhCouponDto.setExpirationDate(DateUtil.parseDateStandardFormat((String)dataMap.get("ExpirationDate")));
            yhCouponDto.setCancelUser((String) dataMap.get("CancelUser"));
            yhCouponDto.setCouponsCode((String)dataMap.get("CouponsCode"));
            yhCouponDto.setMinConsumeAmount((Double) dataMap.get("MinConsumeAmount"));
            yhCouponDto.setCouponAmount((Double) dataMap.get("CouponAmount"));
            yhCouponDto.setCouponName((String)dataMap.get("CouponName"));
            yhCouponDto.setCouponTicketsCode((String)dataMap.get("CouponTicketsCode"));
            yhCouponDto.setCouponType((String)dataMap.get("CouponType"));
            yhCouponDto.setType((String)dataMap.get("Type"));
            yhCouponDto.setCardType((String)dataMap.get("CardType"));
            yhCouponDto.setMobiePhone((String)dataMap.get("MobiePhone"));
            yhCouponDto.setBusinessNo((String)dataMap.get("BusinessNo"));
            yhCouponDto.setAppId((String)dataMap.get("AppId"));
            yhCouponDto.setCancelHotelCode((String)dataMap.get("CancelHotelCode"));
            yhCouponDto.setUserHotelCode((String)dataMap.get("UserHotelCode"));
            return yhCouponDto;
        }).collect(Collectors.toList());
        QueryResult<YhCouponDto> yhCouponDtoQueryResult=new QueryResult<>();
        yhCouponDtoQueryResult.setResultlist(yhCouponDtoList);
        yhCouponDtoQueryResult.setTotalrecord(Optional.ofNullable(map.get("TotalCount")).filter(value->null!=value).map(value->Long.parseLong(value.toString())).orElse(null));
        return yhCouponDtoQueryResult;
    }

    @Override
    public QueryResult<YhActivityDto> listYhActivity(String lhotelGroupCode,
                                                     String pmsHotelGroupCode,
                                                     Integer pageIndex,
                                                     Integer pageSize)throws Exception{
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/SvcCard/Activity/GetAllActivityList";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setStatus("A");
        yhMemberInfoRequestParamDto.setActivityType("4");
        yhMemberInfoRequestParamDto.setPageIndex(pageIndex);
        yhMemberInfoRequestParamDto.setPageSize(pageSize);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Optional<Map> mapOptional=Optional.ofNullable(map);
        mapOptional.filter(map1 ->true==(boolean)map.get("Success")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_GET_ACTIVITY_LIST_ERROR));
        List<Map<String,Object>> dataMapList=mapOptional.map(map1 ->(List<Map<String,Object>>) map1.get("Data")).orElse(Collections.emptyList());
        List<YhActivityDto> yhActivityDtoList =dataMapList.stream().map(dataMap->{
            YhActivityDto yhActivityDto=new YhActivityDto();
            yhActivityDto.setActivityCode((String) dataMap.get("ActivityCode"));
            yhActivityDto.setId((Integer) dataMap.get("Id"));
            yhActivityDto.setActivityName((String) dataMap.get("ActivityName"));
            yhActivityDto.setAmount((Double ) dataMap.get("Amount"));
            yhActivityDto.setPoints((Double ) dataMap.get("Points"));
            yhActivityDto.setRemark((String) dataMap.get("Remark"));
            yhActivityDto.setExchangeType((String) dataMap.get("ExchangeType"));
            yhActivityDto.setStartDate(DateUtil.parseDateStandardFormat((String)dataMap.get("StartDate")));
            yhActivityDto.setEndDate(DateUtil.parseDateStandardFormat((String)dataMap.get("EndDate")));
            return yhActivityDto;
        }).collect(Collectors.toList());
        QueryResult<YhActivityDto> yhActivityDtoQueryResult=new QueryResult<>();
        yhActivityDtoQueryResult.setResultlist(yhActivityDtoList);
        yhActivityDtoQueryResult.setTotalrecord(Optional.ofNullable(map.get("TotalCount")).filter(value->null!=value).map(value->Long.parseLong(value.toString())).orElse(null));
        return yhActivityDtoQueryResult;
    }

    @Override
    public YhActivityDto getYhActivity(String lhotelGroupCode, String id)throws Exception{
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/SvcCard/Activity/GetActivity?id="+id;
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setId(id);
        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        String responseBody = HttpUtil.httpPost(uri, yhMemberInfoRequestParamDto, headers);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        Optional<Map> mapOptional=Optional.ofNullable(map);
        mapOptional.filter(map1 ->true==(boolean)map.get("Success")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_GET_ACTIVITY_ERROR));
        Map<String,Object> dataMap=mapOptional.map(map1 ->(Map<String,Object>) map1.get("Data")).orElseThrow(()->new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_GET_ACTIVITY_ERROR,"数据不存在"));
        YhActivityDto yhActivityDto=new YhActivityDto();
        yhActivityDto.setActivityCode((String) dataMap.get("ActivityCode"));
        yhActivityDto.setId((Integer) dataMap.get("Id"));
        yhActivityDto.setActivityName((String) dataMap.get("ActivityName"));
        yhActivityDto.setAmount((Double ) dataMap.get("Amount"));
        yhActivityDto.setPoints((Double ) dataMap.get("Points"));
        yhActivityDto.setRemark((String) dataMap.get("Remark"));
        yhActivityDto.setExchangeType((String) dataMap.get("ExchangeType"));
        return yhActivityDto;
    }


    @Override
    public String exchangePackage(String lhotelGroupCode,
                                  String pmsHotelGroupCode,
                                  String cardNo,
                                  String activityCode,
                                  String exchangeType,
                                  String activityDate,
                                  String mobile,
                                  Double amount,
                                  Integer points) throws Exception {
        String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/SvcCard/Coupon/MoneyExchangeCouponList";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        //yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setUserHotelCode("0000000");
        yhMemberInfoRequestParamDto.setActivityCode(activityCode);
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setExchangeType(exchangeType);
        yhMemberInfoRequestParamDto.setPhone(mobile);
        yhMemberInfoRequestParamDto.setAmount(amount);
        yhMemberInfoRequestParamDto.setPoints(points);
        yhMemberInfoRequestParamDto.setActivityDate(activityDate);
        yhMemberInfoRequestParamDto.setStatus("A");
        yhMemberInfoRequestParamDto.setModifyUser(DefaultValue.LINK2ROOM);

        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        logger.info("exchangePackage请求yh：{}",yhMemberInfoRequestParamDto);
        String responseBody = HttpUtil.httpPut(uri, yhMemberInfoRequestParamDto, headers);
        logger.info("exchangePackage接收yh应答：{}",responseBody);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        if(false==(boolean)map.get("Success")){
            throw new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_EXCHANGEPACKAGE_ERROR, map.get("Code")+(String)map.get("Message"));
        }else {
            return responseBody;
        }
    }

	@Override
	public String coupenCodeCollarCoupen(String lhotelGroupCode, String pmsHotelGroupCode, String cardNo, String couponsCode, String couponsCodeType, String mobile) throws Exception {
		String clientIp = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.CONFIG_CATEGORY, YhPmsConstant.CONFIG_ITEM.MEMBER_CLIENTIP);
        String hotelCode = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTHOTELCODE);
        String cardLevel = SysoptionUtil.getSysOption(lhotelGroupCode, YhPmsConstant.MEMBER_CONFIG_CATEGORY, YhPmsConstant.MEMBER_CONFIG_ITEM.DEFAULTCARDLEVEL);
        L2RAssert.stringBlank(hotelCode, "默认酒店代码不存在");
        L2RAssert.stringBlank(cardLevel, "默认会员等级不存在");
        String uri = clientIp + "/" + "api/SvcCard/Cou/CoupenCodeCollarCoupen";
        YhMemberInfoRequestParamDto yhMemberInfoRequestParamDto = new YhMemberInfoRequestParamDto();
        yhMemberInfoRequestParamDto.setGroupCode(pmsHotelGroupCode);
        yhMemberInfoRequestParamDto.setHotelCode(hotelCode);
        yhMemberInfoRequestParamDto.setUserHotelCode("0000000");
        yhMemberInfoRequestParamDto.setCardNo(cardNo);
        yhMemberInfoRequestParamDto.setPhone(mobile);
        yhMemberInfoRequestParamDto.setCreateUser(DefaultValue.LINK2ROOM);
        yhMemberInfoRequestParamDto.setCouponsCode(couponsCode);
        yhMemberInfoRequestParamDto.setCouponsCodeType(couponsCodeType);

        Header[] headers = YhPmsUtil.getYhRequestHeader(lhotelGroupCode,YhPmsConstant.MEMBER_REQ );
        logger.info("coupenCodeCollarCoupen请求yh：{}",yhMemberInfoRequestParamDto);
        String responseBody = HttpUtil.httpPut(uri, yhMemberInfoRequestParamDto, headers);
        logger.info("coupenCodeCollarCoupen接收yh应答：{}",responseBody);
        Map map = JacksonUtil.jsonToBeanByJavaType(responseBody, Map.class, String.class,Object.class);
        if(false==(boolean)map.get("Success")){
            throw new SoundwaveException(SoundwaveSysExceptionEnum.YHPMS_COUPENCODECOLLARCOUPEN_ERROR.getCode(), (String)map.get("Message"), "");
        }else {
            return responseBody;
        }
	}
}
